using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace xingzhimeng
{
    ///<summary>
    ///
    ///</summary>
    public class Enemy : MonoBehaviour
    {
        private Animation anima;
        public string ClipName;

        private void Start()
        {
            anima = GetComponent<Animation>();
        }

        private void OnCollisionEnter(Collision other)
        {
            if (other.collider.tag == "Bullet")
            {  
                AudioSource.PlayClipAtPoint(Gun.collSource,EnemyManager.insernt.transform.position);
                Destroy(other.gameObject);
                CollBullet();
            }
        }

        void CollBullet()
        {
            GetComponent<BoxCollider>().enabled = false;
            ShootScoreManager.insernt.ResetScore(5);
            anima.Play(ClipName);
            Destroy(gameObject,0.8f);
            
        }
    }
}